﻿namespace Anurgath.Shoutbox.Services
{
    #region Usings
    using Anurgath.Shoutbox.Models;
    using Orchard;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Orchard.ContentManagement;
    using Orchard.Environment;
    #endregion

    public class ShoutboxService : IShoutboxService
    {
        #region Private variables
        private readonly Work<IOrchardServices> _OrchardServices;
        #endregion

        #region Constructors
        public ShoutboxService(Work<IOrchardServices> orchardServices)
        {
            if (orchardServices == null)
            {
                throw new ArgumentNullException("orchardServices");
            }

            _OrchardServices = orchardServices;
        }
        #endregion

        #region Methods
        public ShoutboxPart GetShoutboxById(int shoutboxId)
        {
            return _OrchardServices.Value.ContentManager.Query<ShoutboxPart>().List().Where(g => g.Id == shoutboxId).FirstOrDefault();
        }
        #endregion
    }
}